package com.ylr.retrofitLearning.Interceptor.globalInterceptor;

import com.github.lianjiatech.retrofit.spring.boot.interceptor.BaseGlobalInterceptor;
import okhttp3.Request;
import okhttp3.Response;
import org.springframework.stereotype.Component;

import java.io.IOException;

/**
 * @Classname SourceInterceptor
 * @Description TODO 全局应用拦截器   在整个系统发起的http请求，都带上来源信息
 * @Date 2021/7/26 10:32
 * @Created by ylr
 */
@Component
public class SourceInterceptor extends BaseGlobalInterceptor {
    @Override
    public Response doIntercept(Chain chain) throws IOException {
        Request request = chain.request();
        Request newreq = request.newBuilder()
                .addHeader("source", "test")
                .build();

        return chain.proceed(newreq);

    }
}
